namespace FineUtil.Simplex
{
 
    /// <summary>
    /// A pair of elements. A value object.
    /// </summary>
    /// <typeparam name="TA">type of the first element.</typeparam>
    /// <typeparam name="TB">type of the second element.</typeparam>
    public class Pair<TA,TB>
    {
        /// <summary>
        /// The first element.
        /// </summary>
        public readonly TA A;

        /// <summary>
        /// The second element.
        /// </summary>
        public readonly TB B;


        /// <summary>
        /// Trivial constructor.
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        public Pair(TA a, TB b)
        {
            A = a;
            B = b;
        }



        ///<summary>
        ///Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
        ///</summary>
        ///
        ///<returns>
        ///A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
        ///</returns>
        ///<filterpriority>2</filterpriority>
        public override string ToString()
        {
            return '(' + A.ToString() + ',' + B.ToString() + ')';
        }



        public override int GetHashCode()
        {
            return (A != null ? A.GetHashCode() : 0) + 29*(B != null ? B.GetHashCode() : 0);
        }



        public override bool Equals(object obj)
        {
            if (this == obj) return true;
            Pair<TA, TB> pair = obj as Pair<TA, TB>;
            if (pair == null) return false;
            if (!Equals(A, pair.A)) return false;
            if (!Equals(B, pair.B)) return false;
            return true;
        }
    }
    
    
}